
(defvar 符号位置序列号 0)

(defmacro cyl-serial()
  `(progn (setq 符号位置序列号 (+ 符号位置序列号 1)) 符号位置序列号))

(defmacro tr-string(par-l &rest body)
    (if (= (length par-l) 4)
	(let ((___i (car par-l))(___c (cadr par-l))(___l (nth 2 par-l))(___n (nth 3 par-l)))
	  (if (and (symbolp ___i)(symbolp ___c)(or (symbolp ___l)(stringp ___l))(or (symbolp ___n)(integerp ___n)))
	      `(let ((___len (length ,___l)))
		 (cl-do ((,___i ,___n (+ ,___i 1)))
		     ((>= ,___i ___len) ,___i)
		   (let ((,___c (string-to-char (substring ,___l ,___i nil))))
		     ,@body
		     )))
	      (message "错误提示：参数类型不合法。")))
      (message "错误提示：参数数量不合法。")))
(defmacro tr-string-step(par-l &rest body)
    (if (= (length par-l) 5)
	(let ((___i (car par-l))(___c (cadr par-l))(___l (nth 2 par-l))(___n (nth 3 par-l))(___step (nth 4 par-l)))
	  (if (and (symbolp ___i)(symbolp ___c)(or (symbolp ___l)(stringp ___l))(or (symbolp ___n)(integerp ___n)))
	      `(let ((___len (length ,___l)))
		 (cl-do ((,___i ,___n (+ ,___i ,___step)))
		     ((if (> ,___step 0) (>= ,___i ___len) (< ,___i 0)) ,___i)
		   (let ((,___c (string-to-char (substring ,___l ,___i nil))))
		     ,@body
		     )))
	      (message "错误提示：参数类型不合法。")))
      (message "错误提示：参数数量不合法。")))
(defmacro tr-list(par-l &rest body)
    (if (= (length par-l) 4)
	(let ((___i (car par-l))(___c (cadr par-l))(___l (nth 2 par-l))(___n (nth 3 par-l)))
	  (if (and (symbolp ___i)(symbolp ___c)(or (symbolp ___l)(listp ___l))(or (symbolp ___n)(integerp ___n)))
	      `(let ((___len (length ,___l)))
		 (cl-do ((,___i ,___n (+ ,___i 1)))
		     ((>= ,___i ___len) ,___i)
		   (let ((,___c (nth ,___i ,___l)))
		     ,@body
		     )))
	      (message "错误提示：参数类型不合法。")))
	(message "错误提示：参数数量不合法。")))
(defmacro tr-list-step(par-l &rest body)
    (if (= (length par-l) 5)
	(let ((___i (car par-l))(___c (cadr par-l))(___l (nth 2 par-l))(___n (nth 3 par-l))(___step (nth 4 par-l)))
	  (if (and (symbolp ___i)(symbolp ___c)(or (symbolp ___l)(listp ___l))(or (symbolp ___n)(integerp ___n)))
	      `(let ((___len (length ,___l)))
		 (cl-do ((,___i ,___n (+ ,___i ,___step)))
		     ((if (> ,___step 0) (>= ,___i ___len) (< ,___i 0)) ,___i)
		   (let ((,___c (nth ,___i ,___l)))
		     ,@body
		     )))
	      (message "错误提示：参数类型不合法。")))
      (message "错误提示：参数数量不合法。")))


(defmacro loop(&rest body)
 `(cl-block breakout (while t ,@body)))

(defmacro dolist-n(par-l &rest body)
   (if (= (length par-l) 3)
	(let ((___i (car par-l))(___l (cadr par-l))(___n (nth 2 par-l)))
	  (if (and (symbolp ___i)(or (symbolp ___l)(listp ___l))(or (symbolp ___n)(integerp ___n)))
	      `(let ((___len (length ,___l)))
		 (cl-do ((___k ,___n (+ 1 ___k)))
			 ((>= ___k ___len) ___k)
			 (let ((,___i (nth ___k ,___l)))
			 ,@body
			 )))
	      (message "错误提示：参数类型不合法。")))
      (message "错误提示：参数数量不合法。")))
 
(defun nth-str(i s)
  (if (>= i (length s)) nil (string-to-char (substring s i nil))))

(defmacro dostring(par-l &rest body)
   (if (= (length par-l) 2)
	(let ((___i (car par-l))(___l (cadr par-l)))
	  (if (and (symbolp ___i)(or (symbolp ___l)(stringp ___l)))
	      `(let ((___len (length ,___l)))
		 (cl-do ((___k 0 (+ 1 ___k)))
		      ((>= ___k ___len) ___k)
		       (let ((,___i (string-to-char (substring ,___l ___k nil))))
			 ,@body
		     )))
	      (message "错误提示：参数类型不合法。")))
      (message "错误提示：参数数量不合法。")))
 
(defmacro dostring-n(par-l &rest body)
   (if (= (length par-l) 3)
	(let ((___i (car par-l))(___l (cadr par-l))(___n (nth 2 par-l)))
	  (if (and (symbolp ___i)(or (symbolp ___l)(stringp ___l))(or (symbolp ___n)(integerp ___n)))
	      `(let ((___len (length ,___l)))
		 (cl-do ((___k ,___n (+ 1 ___k)))
		      ((>= ___k ___len) ___k)
		       (let ((,___i (string-to-char (substring ,___l ___k nil))))
			 ,@body
		     )))
	      (message "错误提示：参数类型不合法。")))
      (message "错误提示：参数数量不合法。")))
 

(defmacro travel-list(data index &rest body)
    `(let ((,index ,data)(___fn (lambda(,index) ,@body)))
       (tra-list ,index '___fn)))
(defun tra-list(l fn)
  (if (null l) nil
      (if (atom l) (funcall fn l)
	  (cons (tra-list (car l) fn)(tra-list (cdr l) fn)))))
      
